using System;
using System.Diagnostics;
using System.IO;
using System.Collections.Generic;
using org.tmatesoft.svn.core;
using org.tmatesoft.svn.core.wc;

namespace Subsync.Core.Subversion
{
	/// <summary>
	/// Author: Tsz Lai
	/// </summary>
	public class SVNPropDel : CommandBase
	{
		/// <summary>
		/// We have our variables declared here.
		/// Access modifiers as you can observe, is public. Why?
		/// Because we trust our programmers.
		/// 
		/// Try to be verbose with the variable names.
		/// Also, try to include *sane defaults*. Take peg_revision for eg.
		/// </summary>
		private java.io.File destination_path;
		private string propName;
		private SVNPropertyValue propValue;
		private bool force;
		private SVNDepth depth;
		private ISVNPropertyHandler handler;
		private java.util.Collection changelist;
		
		public SVNPropDel(string dest_path, string Name)
        {
			Console.WriteLine("SVN Switch normal Constructor");
			
			this.destination_path = new java.io.File(dest_path);
			this.propName = Name;
			this.propValue = null;
			this.force = true;
			this.depth = SVNDepth.INFINITY;
			this.handler = null;
			this.changelist = null;
		}

		/// <summary>
		/// Execute SVN Checkout
		/// </summary>
		public override void Execute ()
		{
			//DEBUG MSG. *Always* include this.
			Console.WriteLine("SVN propdel Execution");
			
			//library setup
			Tools.SetupLibrary();
			
			//load up the clients
			SVNClientManager cm = SVNClientManager.newInstance();
			SVNWCClient wc = cm.getWCClient();	
			
			try
            {
				wc.doSetProperty (this.destination_path, this.propName, this.propValue, 
				              this.force, this.depth, this.handler, this.changelist);							
			}
			catch (SVNException e)
            {
				//we convert this exception to a non SVNKit exception.
				//we want to minimize interfacing with SVNkit outside of this namespace (abstraction)
				throw new SVNExecuteException(e.getMessage());
			}
		}
	}
}
